//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.web.controller.workflow;

import com.aidong.dao.wills.MemberContractDao;
import com.aidong.dao.wills.MemberEarnestDao;
import com.aidong.dao.wills.MemberInfoDao;
import com.aidong.dao.wills.PssProductSaleDao;
import com.aidong.dao.wills.PtBespeakDao;
import com.aidong.dao.wills.PtContractDao;
import com.aidong.dao.wills.WorkflowFileDao;
import com.aidong.dao.wills.WorkflowListDao;
import com.aidong.model.wills.MemberContract;
import com.aidong.model.wills.MemberEarnest;
import com.aidong.model.wills.PssProductSale;
import com.aidong.model.wills.PtBespeak;
import com.aidong.model.wills.PtContract;
import com.aidong.model.wills.WorkflowDetail06;
import com.aidong.model.wills.WorkflowList;
import com.aidong.util.FuncUtil;
import com.aidong.web.controller.BaseController;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

public class WorkflowController extends BaseController {
    @Resource
    WorkflowListDao workflowListDao;
    @Resource
    WorkflowFileDao workflowFileDao;
    @Resource
    MemberInfoDao memberInfoDao;
    @Resource
    MemberContractDao memberContractDao;
    @Resource
    PtContractDao ptContractDao;
    @Resource
    MemberEarnestDao memberEarnestDao;
    @Resource
    PssProductSaleDao pssProductSaleDao;
    @Resource
    PtBespeakDao ptBespeakDao;

    public WorkflowController() {
    }

    @RequestMapping({"getDetail"})
    public ModelAndView getDetail(@RequestParam("id") int id) {
        WorkflowList workflow = (WorkflowList)this.workflowListDao.getById(Integer.valueOf(id));
        if(workflow == null) {
            return this.showAlert("没有这个申请");
        } else {
            Object detail = this.workflowListDao.getWorkflowDetail(Integer.valueOf(id), workflow.getTypeId());
            ModelAndView mv = new ModelAndView("workflow/detail/detail" + workflow.getTypeId());
            mv.addObject("workflow", workflow);
            mv.addObject("detail", detail);
            mv.addObject("_picPath", this.getSetting("pic.path"));
            if(!this.chkNull(workflow.getContractCode()) && FuncUtil.strInArray(workflow.getTypeId(), new String[]{"04", "08", "09", "10", "11", "12", "13", "14", "17", "20", "23", "24", "25", "26", "27", "30", "31", "34"})) {
                MemberContract productSale3 = this.memberContractDao.getByContractCode(workflow.getContractCode());
                mv.addObject("contract", productSale3);
            } else if(!this.chkNull(workflow.getContractCode()) && FuncUtil.strInArray(workflow.getTypeId(), new String[]{"02", "05", "06", "07", "15", "16", "18", "19", "21", "22"})) {
                PtContract productSale2 = this.ptContractDao.getByContractCode(workflow.getContractCode());
                mv.addObject("contract", productSale2);
                if("06".equals(workflow.getTypeId())) {
                    PtBespeak bespeak = (PtBespeak)this.ptBespeakDao.getById(((WorkflowDetail06)detail).getPtBespeakId());
                    mv.addObject("bespeak", bespeak);
                }
            } else if(!this.chkNull(workflow.getContractCode()) && FuncUtil.strInArray(workflow.getTypeId(), new String[]{"03", "28"})) {
                MemberEarnest productSale1 = (MemberEarnest)this.memberEarnestDao.getById(this.parseInt(workflow.getContractCode()));
                mv.addObject("earnest", productSale1);
            } else if("32".equals(workflow.getTypeId())) {
                PssProductSale productSale = (PssProductSale)this.pssProductSaleDao.getById(this.parseInt(workflow.getContractCode()));
                mv.addObject("productSale", productSale);
            }

            return mv;
        }
    }

    @RequestMapping({"viewFile"})
    public ModelAndView viewFile(@RequestParam("id") int id) {
        WorkflowList workflow = (WorkflowList)this.workflowListDao.getById(Integer.valueOf(id));
        if(workflow == null) {
            return this.showAlert("没有这个申请!");
        } else {
            List flist = this.workflowFileDao.getListByWorkflowId(id);
            ModelAndView mv = new ModelAndView("workflow/detail/file");
            mv.addObject("workflow", workflow);
            mv.addObject("flist", flist);
            mv.addObject("_picPath", this.getSetting("pic.path"));
            return mv;
        }
    }

    @RequestMapping({"viewHis"})
    public ModelAndView viewHis(@RequestParam("id") int id) {
        WorkflowList workflow = (WorkflowList)this.workflowListDao.getById(Integer.valueOf(id));
        if(workflow == null) {
            return this.showAlert("没有这个申请!");
        } else {
            ModelAndView mv = new ModelAndView("workflow/detail/his");
            mv.addObject("workflow", workflow);
            return mv;
        }
    }
}
